﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
using System;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.ApplicationPages;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;
using System.Web;
namespace Microsoft.MCSUK.SPSiteDirectory2010
{
    public class ResetGlobalSettings : LayoutsPageBase
    {
        protected System.Web.UI.WebControls.Literal ErrorMessageLiteral;
        protected Microsoft.SharePoint.WebControls.WebApplicationSelector WebAppSelector;
        protected System.Web.UI.WebControls.Button OKButton;
        protected System.Web.UI.WebControls.Label SiteDirectoryWebAppLabel;
        protected System.Web.UI.WebControls.DropDownList SiteDirectorySite;
        protected System.Web.UI.WebControls.Label SiteDirectoryStatusLabel;
        protected System.Web.UI.WebControls.Button DisableButton;
        protected Microsoft.SharePoint.WebControls.SiteAdministrationSelector SiteCollectionSelector;

        protected void OKButton_OnClick(object sender, EventArgs e)
        {
            GlobalMethods globalMethods = new GlobalMethods();
            try
            {
                globalMethods.ResetGlobalSolutionSettings(SPFarm.Local);
                SPUtility.Redirect(GlobalConstants.CentralAdminRedirectURL, SPRedirectFlags.Trusted | SPRedirectFlags.DoNotEndResponse, this.Context);
            }
            catch (Exception ex)
            {
                ErrorMessageLiteral.Text = HttpContext.GetGlobalResourceObject("SPSiteDirectory2010GlobalResources", "Code_GenericUIErrorText").ToString();
                globalMethods.WriteULSEntry(ex, TraceSeverity.Unexpected, null);
            }
        }
    }
}
